package com.star.star.fragment;

import android.os.Bundle;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;


public class AbBanner extends Fragment {
    private int adsId;
    private ImageView imageView;
    public static AbBanner newInstance(int adsId) {//调用该静态方法，返回一个新的对象
        AbBanner ar=new AbBanner();
        ar.adsId=adsId;
        return ar;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        imageView=new ImageView(getContext());
        imageView.setScaleType(ImageView.ScaleType.FIT_XY);//如果里面的图片大小比imageView的尺寸要小则，拉升
        return imageView;
    }

    @Override
    public void onResume() {//当界面显示屏幕上时执行，作用：设置界面元素的内容
        super.onResume();
        imageView.setImageResource(adsId);
    }
}
